gtk_progress_bar_set_fraction (pbar, fraction);
}
+static void
+clicked_cb (GtkGesture *gesture,
+ int n_press,
+ double x,
+ double y,
+ GtkPopover *popover)
+{
+ GdkRectangle rect;
+
+ rect.x = x;
+ rect.y = y;
+ rect.width = 1;
+ rect.height = 1;
+ gtk_popover_set_pointing_to (popover, &rect);
+ gtk_popover_popup (popover);
+}
+
+static void
+set_up_context_popover (GtkWidget *widget,
+ GMenuModel *model)
+{
+ GtkWidget *popover = gtk_popover_new_from_model (widget, model);
+ GtkGesture *gesture;
+
+ g_object_set (popover, "has-arrow", FALSE, NULL);
+ gesture = gtk_gesture_click_new ();
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
+ g_signal_connect (gesture, "pressed", G_CALLBACK (clicked_cb), popover);
+ gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
+}
+
static void
activate (GApplication *app)
{
GtkWidget *dialog;
GtkAdjustment *adj;
GtkCssProvider *provider;
+ GMenuModel *model;
static GActionEntry win_entries[] = {
{ "dark", NULL, NULL, "false", change_theme_state },
{ "transition", NULL, NULL, "false", change_transition_state },
} accels[] = {
{ "app.about", { "F1", NULL } },
{ "app.quit", { "<Primary>q", NULL } },
+ { "app.open", { "Return", NULL } },
{ "app.open-in", { "<Primary>n", NULL } },
+ { "app.cut", { "<Primary>x", NULL } },
+ { "app.copy", { "<Primary>c", NULL } },
+ { "app.paste", { "<Primary>v", NULL } },
{ "win.dark", { "<Primary>d", NULL } },
{ "win.search", { "<Primary>s", NULL } },
{ "win.delete", { "Delete", NULL } },
widget = (GtkWidget *)gtk_builder_get_object (builder, "extra_info_entry");
g_timeout_add (100, (GSourceFunc)pulse_it, widget);
+ widget = (GtkWidget *)gtk_builder_get_object (builder, "box_for_context");
+ model = (GMenuModel *)gtk_builder_get_object (builder, "new_style_context_menu_model");
+ set_up_context_popover (widget, model);
+
gtk_widget_show (GTK_WIDGET (window));
g_object_unref (builder);
GVariant *parameter,
gpointer user_data)
{
- g_print ("Set action %s to %s\n",
+ g_print ("Select action %s value %s\n",
g_action_get_name (G_ACTION (action)),
g_variant_get_string (parameter, NULL));
{ "print", activate_action, NULL, NULL, NULL },
{ "share", activate_action, NULL, NULL, NULL },
{ "labels", activate_action, NULL, NULL, NULL },
+ { "open", activate_action, NULL, NULL, NULL },
{ "open-in", activate_action, NULL, NULL, NULL },
+ { "open-tab", activate_action, NULL, NULL, NULL },
+ { "open-window", activate_action, NULL, NULL, NULL },
{ "cut", activate_action, NULL, NULL, NULL },
{ "copy", activate_action, NULL, NULL, NULL },
{ "paste", activate_action, NULL, NULL, NULL },
{ "broni", toggle_action, NULL, "true", NULL },
{ "drutt", toggle_action, NULL, "true", NULL },
{ "upstairs", toggle_action, NULL, "true", NULL },
+ { "option-a", activate_action, NULL, NULL, NULL },
+ { "option-b", activate_action, NULL, NULL, NULL },
+ { "option-c", activate_action, NULL, NULL, NULL },
+ { "option-d", activate_action, NULL, NULL, NULL },
};
gint status;
<object class="GtkNotebookPage">
<property name="tab-expand">1</property>
<property name="child">
- <object class="GtkBox">
+ <object class="GtkBox" id="box_for_context">
<property name="height-request">120</property>
</object>
</property>
</item>
</section>
</menu>
+ <menu id="new_style_context_menu_model">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Open</attribute>
+ <attribute name="action">app.open</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Open in New Tab</attribute>
+ <attribute name="action">app.open-tab</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Open in New Window</attribute>
+ <attribute name="action">app.open-window</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Cut</attribute>
+ <attribute name="action">app.cut</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Copy</attribute>
+ <attribute name="action">app.copy</attribute>
+ </item>
+ </section>
+ <section>
+ <submenu>
+ <attribute name="label" translatable="yes">Options</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Option A</attribute>
+ <attribute name="action">app.option-a</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Option B</attribute>
+ <attribute name="action">app.option-b</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Option C</attribute>
+ <attribute name="action">app.option-c</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Option D</attribute>
+ <attribute name="action">app.option-d</attribute>
+ </item>
+ </section>
+ </submenu>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Move to Trash</attribute>
+ <attribute name="action">win.delete</attribute>
+ </item>
+ </section>
+ </menu>
</interface>